﻿using System;
using System.Data;
using BEGDC.Utility.Castle;
using BEGDC.Utility.NHibernate;
using Castle.Services.Transaction;
using NHibernate;
using NHibernate.Expression;
using Nullables;

namespace BEGDC.PreContract.BLL
{
    public partial class ProblemLVAssignment : IProblemLVAssignment
    {
        public const string CONST_PROBLEMLVASSIGNMENT = @"select * from ProblemLVAssignment ";

        public int GetProblemLV1IDByProblemLV2ID(int problemLV2ID)
        {
            using (ISession session = factory.OpenSession())
            {
                string strSql = CONST_PROBLEMLVASSIGNMENT + string.Format(" where ProblemLV2ID = {0}", problemLV2ID);

                DataTable dtSearch = DAO.ExecuteDataTable(session, strSql);

                return (dtSearch != null && dtSearch.Rows.Count > 0) ? Convert.ToInt32(dtSearch.Rows[0]["ProblemLV1ID"]) : 0;
            }
        }
    }
}
